const AnalysisModel = require('../models/analysisModel')
class AnalysisController {
    // 成绩分布图数据获取
    static async score_chart (req,res){
        let {class_id, program_id, exam_id} = req.query
        try {
            let results = await AnalysisModel.score_chart(class_id, program_id, exam_id)
             
            res.json({ code: 0, msg: "成绩分布图数据获取成功！", results })
        } catch (error) {
            console.log(error)
            res.json({ code: 0, msg: error })
        }
    }
    // 出勤率趋势表--Attendance
    static async attend_chart (req,res){
        let {class_id, program_id, start_time, end_time} = req.query
        try {
            let results = await AnalysisModel.attend_chart(class_id, program_id, start_time, end_time)
             
            res.json({ code: 0, msg: "出勤率趋势表数据获取成功！", results })
        } catch (error) {
            console.log(error)
            res.json({ code: 0, msg: error })
        }
    }
    // 学习进度追踪图
    static async progress_chart (req,res){
        let {class_id, program_id, start_time, end_time} = req.query
        try {
            let results = await AnalysisModel.progress_chart(class_id, program_id, start_time, end_time)
             
            res.json({ code: 0, msg: "学习进度追踪图数据获取成功！", results })
        } catch (error) {
            console.log(error)
            res.json({ code: 0, msg: error })
        }
    }
    // 内务分数排行图
    static async housekeep_chart (req,res) {
        let {class_id, program_id, start_time, end_time} = req.query
        try {
            let results = await AnalysisModel.housekeep_chart(class_id, program_id, start_time, end_time)
             
            res.json({ code: 0, msg: "内务分数排行图数据获取成功！", results })
        } catch (error) {
            console.log(error)
            res.json({ code: 0, msg: error })
        }
    }
    // 1.成绩排名图表
    static async classRank_chart(req,res) {
        let { start_time, end_time} = req.query
        try {
            let results = await AnalysisModel.classRank_chart(start_time, end_time)
             
            res.json({ code: 0, msg: "成绩排名图表数据获取成功！", results })
        } catch (error) {
            console.log(error)
            res.json({ code: 0, msg: error })
        }
    }
    // 2.考勤排名图表
    static async attendRank_chart(req,res) {
        let { start_time, end_time} = req.query
        try {
            let results = await AnalysisModel.attendRank_chart(start_time, end_time)
             
            res.json({ code: 0, msg: "考勤排名图表数据获取成功！", results })
        } catch (error) {
            console.log(error)
            res.json({ code: 0, msg: error })
        }
    }
    // 3.内务排名图表
    static async housekeepRank_chart(req,res) {
        let { start_time, end_time} = req.query
        try {
            let results = await AnalysisModel.housekeepRank_chart(start_time, end_time)
             
            res.json({ code: 0, msg: "内务排名图表数据获取成功！", results })
        } catch (error) {
            console.log(error)
            res.json({ code: 0, msg: error })
        }
    }
    // 4.作业分数排名图表
    static async homeworkRank_chart(req,res) {
        let { start_time, end_time} = req.query
        try {
            let results = await AnalysisModel.homeworkRank_chart(start_time, end_time)
             
            res.json({ code: 0, msg: "作业分数排名图表数据获取成功！", results })
        } catch (error) {
            console.log(error)
            res.json({ code: 0, msg: error })
        }
    }
    // 三. 学习成绩分析
    // 1.学生折线统计图-所有成绩的对比
    static async allScore_chart(req,res) {
        let { start_time, end_time} = req.query
        try {
            let results = await AnalysisModel.allScore_chart(start_time, end_time)
             
            res.json({ code: 0, msg: "学生所有成绩对比图表数据获取成功！", results })
        } catch (error) {
            console.log(error)
            res.json({ code: 0, msg: error })
        }
    }
    // 2.班级平均分趋势表
    static async average_chart(req,res) {
        let { start_time, end_time} = req.query
        try {
            let results = await AnalysisModel.average_chart(start_time, end_time)
             
            res.json({ code: 0, msg: "班级平均分趋势表数据获取成功！", results })
        } catch (error) {
            console.log(error)
            res.json({ code: 0, msg: error })
        }
    }
    // 3.学生成绩明细表格
    static async student_chart(req,res) {
        let { start_time, end_time} = req.query
        try {
            let results = await AnalysisModel.student_chart(start_time, end_time)
             
            res.json({ code: 0, msg: "学生成绩明细表格数据获取成功！", results })
        } catch (error) {
            console.log(error)
            res.json({ code: 0, msg: error })
        }
    }
    // 4.考勤详情表
    static async attenddetail_chart(req,res) {
        try {
            let results = await AnalysisModel.attenddetail_chart()
             
            res.json({ code: 0, msg: "考勤详情表数据获取成功！", results })
        } catch (error) {
            console.log(error)
            res.json({ code: 0, msg: error })
        }
    }
    // 5.作业完成情况表
    static async workcom_chart(req,res) {
        try {
            let results = await AnalysisModel.workcom_chart()
             
            res.json({ code: 0, msg: "作业完成情况表数据获取成功！", results })
        } catch (error) {
            console.log(error)
            res.json({ code: 0, msg: error })
        }
    }
    // 6.作业的完成数量统计
    static async workcom_number(req,res) {
        try {
            let results = await AnalysisModel.workcom_number()
             
            res.json({ code: 0, msg: "作业的完成数量统计数据获取成功！", results })
        } catch (error) {
            console.log(error)
            res.json({ code: 0, msg: error })
        }
    }
}
module.exports = AnalysisController